from flask import make_response
import redis, pymysql


class Redis:
    host = ''
    port = ''
    password = ''

    def createcon(self, database):
        return redis.Redis(connection_pool=redis.ConnectionPool(host=self.host, port=self.port, password=self.password, db=database))


class Mysql:
    host = ''
    port = ''
    username = ''
    password = ''

    def createcon(self, database):
        return pymysql.connect(host=self.host, port=int(self.port), user=self.username, password=self.password, database=database, cursorclass=pymysql.cursors.DictCursor)


class Resp:
    def creatresp(self):
        resp = make_response()
        resp.headers['Access-Control-Allow-Origin'] = ''
        resp.headers['Access-Control-Allow-Headers'] = 'myCookie'
        resp.headers['Access-Control-Allow-Methods'] = 'POST'
        resp.headers['Server'] = 'tomcat/2.5.0'
        resp.access_control_allow_credentials = True

        return resp

class Email:
    sender=''
    key=''
    codeExpiration = 60 * 5

class Other:
    defaultpassword = 'a123456'
    datebase = "onlineCourseWeb"
    webport = 888
    codeExpiration = 60 * 5
    cookieExpiration = 60 * 60 * 12
    homeListExpiration = 60 * 60 * 24 * 15
